﻿@{
    ViewBag.Title = "人员列表";
    Layout = null;
}
@model EIP.Web.AdminLTE.Areas.System.Models.SystemPermissionUserModel
<div class="row">
    <div class="col-md-12">
        <div class="box box-primary box-solid">
            <div class="box-header with-border">
                <h3 class="box-title">角色人员列表</h3>
               
            </div>
            <div class="box-body no-padding">
                <div class="mailbox-controls">
                    <div class="btn-group" id="partial_button_toolbar">
                        <a onclick=" addPrivilegeMasterUser(); return false; " title="" data-toggle="tooltip" class="btn btn-default btn-sm" href="javascript:void(0)" data-original-title="新增">
                            <i class="fa fa-plus">新增</i>
                        </a>

                        <a onclick=" delPrivilegeMasterUser(); return false; " title="" data-toggle="tooltip" class="btn btn-default btn-sm" href="javascript:void(0)" data-original-title="删除">
                            <i class="fa fa-close">删除</i>
                        </a>
                    </div>
                </div>
                <div class="mailbox-jqgrid">
                    <table id="privilegeMasterUserlist"></table>
                    <div id="privilegeMasterUserPager"></div>
                </div>
            </div>
        </div>
    </div>
</div>
@Html.HiddenFor(f => f.PrivilegeMaster)
<input class="filter" id="PrivilegeMasterValue" name="PrivilegeMasterValue" type="hidden" value="@Model.PrivilegeMasterValue" />
<script>
   $(function () {
        initPrivilegeMasterUserGrid();
    });

    var $privilegeMasterUserGrid;


    //初始化表格
    function initPrivilegeMasterUserGrid() {
        $privilegeMasterUserGrid = $("#privilegeMasterUserlist").jgridview(
        {
            loadonce: false,
            shrinkToFit: true,
            multiselect: false,
            url: "/Common/UserControl/GetPagingPrivilegeMasterUser",
            colModel: [
                { name: "UserId", hidden: true },
                { label: "登录名", name: "Code", index: "u.Code", width: 120, fixed: true },
                { label: "姓名", name: "Name", index: "u.Name", width: 60, fixed: true },
                { label: "归属组织", name: "OrganizationName", index: "OrganizationId", width: 224, fixed: true },
                { label: "电话号码", name: "Mobile", width: 80 },
                { label: "冻结", name: "IsFreeze", index: "u.IsFreeze", width: 50, align: "center", fixed: true, formatter: "YesOrNo" }
            ],
            postData: {
                filters: getFilters("select_box"),
                privilegeMaster: $("#PrivilegeMaster").val(),
                privilegeMasterValue: $("#PrivilegeMasterValue").val()
            },
            height: "400",
            pager: "privilegeMasterUserPager",
            sortname: "u.CreateTime"
        });
    }

    //获取表格数据
    function getPrivilegeMasterUserGridData() {
        //重新查询
        $privilegeMasterUserGrid.trigger("reloadGrid", [{ page: 1 }]);
    }

    //操作:新增
    function addPrivilegeMasterUser() {
        ArtDialogOpen("/Common/UserControl/ChosenPrivilegeMasterUser?" +
            "privilegeMaster=" + $("#PrivilegeMaster").val() + "&" +
            "privilegeMasterValue=" + $("#PrivilegeMasterValue").val(), "选择人员", true, 450, 830);
    }

    //删除匹配项
    function delPrivilegeMasterUser() {
        //查看是否选中
        GridIsSelect($privilegeMasterUserGrid, function () {
            ArtDialogConfirm(Language.common.deletemsg, function () {
                UtilAjaxPostWait(
                    "/Common/UserControl/DeletePrivilegeMasterUser",
                    {
                        privilegeMasterUserId: GridGetSingSelectData($privilegeMasterUserGrid).UserId,
                        privilegeMasterValue: $("#PrivilegeMasterValue").val(),
                        privilegeMaster: $("#PrivilegeMaster").val()
                    },
                    peratePrivilegeMasterUserStatus
                );
            });
        });
    }

    //请求完成
    function peratePrivilegeMasterUserStatus(data) {
        DialogAjaxResult(data);
        if (data.ResultSign === 0) {
            getPrivilegeMasterUserGridData();
        }
    }

</script>